/**
 * 
 */
package com.pmsco.pms.core.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Where;

/**
 * @author Long Tran
 *
 */
@Entity
@Table(
	name = "MEDICINE"
)
public class Medicine {
	private Long id;
	private String name;
	private String enName;
	private String visa;
	private String ingredient;
	private String directions;
	private String dispenseType;
	private String manufacturer;
	private String distributor;
	private String importer;
	private List<MedicineCategory> medicineCategories;
	private List<MedicineCategory> mainMedicineCategories;
	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue
	@Column(name = "ID", nullable = false)
	public Long getId() {
		return id;
	}
	
	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}
	
	/**
	 * @return the name
	 */
	@Column(name = "NAME", nullable = false)
	public String getName() {
		return name;
	}
	
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * @return the enName
	 */
	@Column(name = "EN_NAME", nullable = false)
	public String getEnName() {
		return enName;
	}

	/**
	 * @param enName the enName to set
	 */
	public void setEnName(String enName) {
		this.enName = enName;
	}

	/**
	 * @return the visa
	 */
	@Column(name = "VISA", nullable = false)
	public String getVisa() {
		return visa;
	}

	/**
	 * @param visa the visa to set
	 */
	public void setVisa(String visa) {
		this.visa = visa;
	}

	/**
	 * @return the ingredient
	 */
	@Column(name = "INGREDIENT", nullable = false)
	public String getIngredient() {
		return ingredient;
	}

	/**
	 * @param ingredient the ingredient to set
	 */
	public void setIngredient(String ingredient) {
		this.ingredient = ingredient;
	}

	/**
	 * @return the directions
	 */
	@Column(name = "DIRECTIONS", nullable = false)
	public String getDirections() {
		return directions;
	}

	/**
	 * @param directions the directions to set
	 */
	public void setDirections(String directions) {
		this.directions = directions;
	}
	
	/**
	 * @return the dispenseType
	 */
	@Column(name = "DISPENSE_TYPE", nullable = true)
	public String getDispenseType() {
		return dispenseType;
	}

	/**
	 * @param dispenseType the dispenseType to set
	 */
	public void setDispenseType(String dispenseType) {
		this.dispenseType = dispenseType;
	}

	/**
	 * @return the manufacturer
	 */
	@Column(name = "MANUFACTURER", nullable = true)
	public String getManufacturer() {
		return manufacturer;
	}

	/**
	 * @param manufacturer the manufacturer to set
	 */
	public void setManufacturer(String manufacturer) {
		this.manufacturer = manufacturer;
	}

	/**
	 * @return the distributor
	 */
	@Column(name = "DISTRIBUTOR", nullable = true)
	public String getDistributor() {
		return distributor;
	}

	/**
	 * @param distributor the distributor to set
	 */
	public void setDistributor(String distributor) {
		this.distributor = distributor;
	}

	/**
	 * @return the importer
	 */
	@Column(name = "IMPORTER", nullable = true)
	public String getImporter() {
		return importer;
	}

	/**
	 * @param importer the importer to set
	 */
	public void setImporter(String importer) {
		this.importer = importer;
	}

	/**
	 * @return the medicineCategories
	 */
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "medicine")
	@Cascade(value = {CascadeType.DELETE_ORPHAN, CascadeType.MERGE, CascadeType.PERSIST})
	public List<MedicineCategory> getMedicineCategories() {
		return medicineCategories;
	}

	/**
	 * @param medicineCategories the medicineCategories to set
	 */
	public void setMedicineCategories(List<MedicineCategory> categories) {
		this.medicineCategories = categories;
	}
	
	/**
	 * @return the mainMedicineCategories
	 */
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "medicine")
	@Cascade(value = {CascadeType.DELETE_ORPHAN, CascadeType.MERGE, CascadeType.PERSIST})
	@Where(clause = "main_category = 'Y'")
	public List<MedicineCategory> getMainMedicineCategories() {
		return mainMedicineCategories;
	}

	/**
	 * @param mainMedicineCategories the mainMedicineCategories to set
	 */
	public void setMainMedicineCategories(
			List<MedicineCategory> mainMedicineCategories) {
		this.mainMedicineCategories = mainMedicineCategories;
	}
	
}
